#include "BaseRecord.h"

Record::Record()
	: m_recording(false)
{
}

Record::~Record()
{
}

std::string Record::GetType()
{
	return m_type;
}

void Record::SetType(std::string id)
{
	m_type = id;
}

std::string Record::GetId()
{
	return m_id;
}

void Record::SetId(std::string v)
{
	m_id = v;
}

std::string Record::GetDeviceId()
{
	return m_deviceId;
}

void Record::SetDeviceId(std::string v)
{
	m_deviceId = v;
}

std::string Record::GetDeviceName()
{
	return m_deviceName;
}

void Record::SetDeviceName(std::string v)
{
	m_deviceName = v;
}

std::string Record::GetPath()
{
	return m_path;
}

void Record::SetPath(std::string v)
{
	m_path = v;
}

int Record::GetDuration()
{
	return m_duration;
}

void Record::SetDuration(int v)
{
	m_duration = v;
}

int Record::GetFrame()
{
	return m_frame;
}

void Record::SetFrame(int v)
{
	m_frame = v;
}

bool Record::GetPreRecord()
{
	return m_preRecord;
}

void Record::SetPreRecord(bool v)
{
	m_preRecord = v;
}

bool Record::GetWriteRecord()
{
	return m_writeRecord;
}

void Record::SetWriteRecord(bool v)
{
	m_writeRecord = v;
}

DateTime Record::GetStartTime()
{
	return m_startTime;
}

void Record::SetStartTime(DateTime v)
{
	m_startTime = v;
}

bool Record::Start(int fps, int width, int height, std::string path)
{
	// 停止录像
	Stop();
	// 录制大小
	cv::Size size = cv::Size(width, height);
	// 打开文件：mp4v|avc1|h264|MJPG|XVID
	bool success = m_witer.open(path.c_str(), cv::VideoWriter::fourcc('a', 'v', 'c', '1'), fps, size);
	// 返回状态
	return m_recording = success, m_recording;
}

void Record::Stop()
{
	if (m_recording)
	{
		m_witer.release();
		m_recording = false;
	}
}

void Record::Write(cv::Mat& frame)
{
	if (m_recording)
	{
		m_witer.write(frame);
	}
}